package com.qd.panda.tf;

import com.cdqidi.dto.ApiResult;
import com.cdqidi.dto.ApiResultWrapper;
import com.fasterxml.jackson.databind.JsonNode;
import com.qd.tfpay.order.BaseResponseBO;
import com.qd.tfpay.order.OrderApi;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author sjk
 */
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/sys/tf/")
@Slf4j
public class TfBankController {
    private final OrderApi orderApi;


    @GetMapping("/queryBalanceByVaccountNo")
    public ApiResultWrapper<JsonNode> queryBalanceByVaccountNo(String partner, String subPartner){
        Map<String,Object> map = new HashMap<>();
        map.put("partner",partner);
        map.put("crossAuthPartner",partner);
        if(StringUtils.hasLength(subPartner)){
            map.put("subpartner",subPartner);
        }
        BaseResponseBO baseResponseBO = orderApi.queryBalanceByVaccountNo(map);
        map.clear();
        return ApiResult.success(baseResponseBO.getOriginalMessage());
    }
}
